// NACL MOD TRACK "third_party/nacl-glibc/sysdeps/nacl/write.c"

#include <errno.h>
#include <unistd.h>
#include <irt_syscalls.h>


ssize_t __write(int desc, void const *buf, size_t count)
{
  if (__nacl_irt_write) {
    size_t nwrite;
    int result = __nacl_irt_write(desc, buf, count, &nwrite);
    if (result != 0) {
      errno = result;
      return -1;
    }
    return (ssize_t) nwrite;
  }

  errno = ENOSYS;
  return -1;
}

weak_alias (__write, write)
